package auth

import (
	"gin-demo/core"
)

// User 用户模型
type User struct {
	core.Model
	Username string `gorm:"not null;unique;size:255" json:"username"`
	Password string `gorm:"not null;size:255" json:"password" `
	IsActive bool   `gorm:"default:true" json:"is_active" `
}

// BeforeCreate 用户创建前的回调函数
func (u *User) BeforeCreate() (err error) {
	u.Password, err = core.EncryptPassword(u.Password)
	return
}
